home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: easy c++ question
- Date: Sat, 20 Apr 1996 04:37:46 GMT
- Organization: Netcom
- Message-ID: <3178695f.194916034@nntp.ix.netcom.com>
- References: <316901DA.3138C677@ablecom.net> <66W25t5UoNB@jth.ping.de> <Pine.OSF.3.91.960411092945.20958C-100000@bud.cc.swin.edu.au> <3172B4A9.6DFF@aai.arco.com> <31783CA2.3FD5@compuserv.com>
- NNTP-Posting-Host: ix-dc16-01.ix.netcom.com
- X-NETCOM-Date: Fri Apr 19 11:38:43 PM CDT 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- "David Visage (Alias Sid)" <"102276,2374"@compuserv.com> wrote:
-
- > > > if you have a class myclass with a constructor and you do
- > > >
- > > > myclass *a;
- > > > a=new myclass[5];
- > > >
- > > > the constructor is not called for every member (a[0], a[1]..)
- > > > Does this help?
- > > > Newbs
- > >
- > > John,
- > >
- > > I am afraid you made a mistake here. The default constructor
- > > is called for each array element. If there is no default
- > > constructor, the array allocation is not allowed.
- >
- > If you do not declare a default constuctor, then the array allocation is allowed.
- >
- > From what I understand, if you do not supply a default constructor, then most
- > compilers will generate one for you. Of course, I could be wrong, but who said
- > I knew everything?
-
- ALL properly working compilers will generate a default constructor
- ONLY IF there is no user-declared constructor.
-
- class A {
- public:
- A(int);
- };
-
- class B {
- };
-
- A a[10]; // illegal -- no default constructor
- B b[10]; // legal -- generated default constructor used
-
-
- Michael M Rubenstein
-